import Vue from 'vue'
import VueRouter from 'vue-router'
import cfg from '@/config'
import {
  constantRouterMap
} from './pages'
Vue.use(VueRouter)

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

const originalReplace = VueRouter.prototype.replace
VueRouter.prototype.replace = function replace(location) {
  return originalReplace.call(this, location).catch(err => err)
}


const router = new VueRouter({
  mode: 'history',
  base: cfg.routerBase,
  routes: constantRouterMap
})

export default router